{% extends 'base.html' %}

{% block content %}
  <h1>班级待办事务列表</h1>
  <a href="{% url 'core:task_create' %}" class="btn btn-primary mb-3"><i class="bi bi-plus-circle me-2"></i>添加待办事务</a>
  <table class="table table-striped">
    <thead>
      <tr>
        <th>班级</th>
        <th>待办内容</th>
        <th>开始时间</th>
        <th>截止时间</th>
        <th>状态</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody>
      {% for task in tasks %}
        <tr>
          <td>{{ task.class_info }}</td>
          <td>{{ task.content|truncatechars:20 }}</td>
          <td>{{ task.start_time|date:"Y-m-d H:i" }}</td>
          <td>{{ task.end_time|date:"Y-m-d H:i" }}</td>
          <td>{% if task.is_completed %}<span class="text-success">已完成</span>{% else %}<span class="text-danger">未完成</span>{% endif %}</td>
          <td>
            <a href="{% url 'core:task_detail' task.pk %}" class="btn btn-sm btn-info"><i class="bi bi-eye me-1"></i>查看</a>
            <a href="{% url 'core:task_update' task.pk %}" class="btn btn-sm btn-warning"><i class="bi bi-pencil me-1"></i>编辑</a>
            <a href="{% url 'core:task_delete' task.pk %}" class="btn btn-sm btn-danger"><i class="bi bi-trash me-1"></i>删除</a>
          </td>
        </tr>
      {% empty %}
        <tr><td colspan="6" class="text-center">暂无待办事务</td></tr>
      {% endfor %}
    </tbody>
  </table>
{% endblock %}